import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/CSS/global.css'
import TreeTable from 'vue-table-with-tree-grid'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import Quill from 'quill'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
import { container, ImageExtend } from 'quill-image-extend-module'
Quill.register('modules/ImageExtend', ImageExtend)

import XLSX from 'xlsx' //导出excel
Vue.prototype.XLSX = XLSX //挂载到全局方法方便调用
Vue.use(VueQuillEditor)

import axios from 'axios'
// 导入显示进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 配置请求的根路径
axios.defaults.baseURL = '/api/'
// 请求拦截器
axios.interceptors.request.use(config => {
  NProgress.start() //开启进度条
  if (config.url.includes('getTestQuestions')) {
    return config
  }
  if (window.sessionStorage.getItem('token')) {
    config.headers.token = window.sessionStorage.getItem('token')
  }
  return config
})
//响应拦截器
axios.interceptors.response.use(config => {
  NProgress.done() //关闭进度条
  return config
})
//挂载axios到全局对象Vue上-->$http
Vue.prototype.$http = axios
Vue.config.productionTip = false

Vue.component('tree-table', TreeTable)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
